package com.infoland.afanmall.model.my.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.infoland.afanmall.R;
import com.infoland.afanmall.base.util.StatusBarKit;
import com.infoland.afanmall.base.util.ToolsKit;
import com.infoland.afanmall.model.my.adapter.ShouCAdapter;
import com.infoland.afanmall.model.my.entity.ShouCEntity;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 收藏Activity
 */
public class ShouCActivity extends AppCompatActivity {


    @BindView(R.id.shou_cang_recy)
    RecyclerView shouCangRecy;
    @BindView(R.id.shou_cang_check_all)
    CheckBox shouCangCheckAll;
    @BindView(R.id.shou_cang_qu_guan)
    TextView shouCangQuGuan;
    List<ShouCEntity> entityList;
    @BindView(R.id.title_layout)
    LinearLayout titleLayout;
    @BindView(R.id.refrensh)
    SmartRefreshLayout refrensh;
    @BindView(R.id.foot)
    LinearLayoutCompat foot;
    @BindView(R.id.bianji)
    TextView bianji;


    private int getLayout() {
        return R.layout.shou_cang_activity;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayout());
        ButterKnife.bind(this);
        StatusBarKit.immersiveBlackTitleText(this, titleLayout);
        StatusBarKit.setMargin(this, refrensh);
        initData();

    }

    private void initData() {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
        shouCangRecy.setLayoutManager(linearLayoutManager);
        shouCangRecy.setAdapter(new ShouCAdapter(R.layout.shou_cang_item, getData(), getApplicationContext()));
    }

    private List getData() {
        entityList = new ArrayList<>();
        entityList.add(new ShouCEntity());
        entityList.add(new ShouCEntity());
        entityList.add(new ShouCEntity());
        entityList.add(new ShouCEntity());
        entityList.add(new ShouCEntity());
        entityList.add(new ShouCEntity());
        return entityList;
    }


    @OnClick({R.id.back, R.id.bianji})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.bianji:
                if ("编辑".equals(bianji.getText())) {
                    bianji.setText("完成");
                    foot.setVisibility(View.VISIBLE);
                } else if ("完成".equals(bianji.getText())) {
                    bianji.setText("编辑");
                    foot.setVisibility(View.GONE);
                }
                break;
        }
    }

    @Override
    protected void onDestroy() {
        ToolsKit.deleteOKHttp(this);
        super.onDestroy();
    }
}
